#!/bin/bash

# 检查工具链是否存在，不存在则安装
# @param $1: 工具链名称
# @param $2: 安装包名称，如果不传则默认为$1
function check-toolchain(){
    if command -v $1 >/dev/null 2>&1 ; then
        echo "check toolchain: ${1} exists"
        return 0;
    fi

    pkg="${1}"
    if [ $# -eq 2 ]; then
        pkg="${2}"
    fi

    echo "check toolchain: ${1} not exists, will install it"
    echo "sudo apt install ${pkg} -y"

    sudo apt install ${pkg} -y
    return 0;
}